//package com.example.springai.config;
//
//import org.springframework.ai.document.MetadataMode;
//import org.springframework.ai.embedding.EmbeddingModel;
//import org.springframework.ai.embedding.TokenCountBatchingStrategy;
//import org.springframework.ai.openai.OpenAiEmbeddingModel;
//import org.springframework.ai.openai.OpenAiEmbeddingOptions;
//import org.springframework.ai.openai.api.OpenAiApi;
//import org.springframework.ai.retry.RetryUtils;
//import org.springframework.ai.vectorstore.VectorStore;
//import org.springframework.ai.vectorstore.redis.RedisVectorStore;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import redis.clients.jedis.JedisPooled;
//
//@Configuration
//public class airedisstore {
//    @Bean
//    public JedisPooled jedisPooled() {
//        return new JedisPooled("127.0.0.1", 6379);
//    }
//    @Bean
//    public EmbeddingModel embeddingModel() {
//
//        var openAiApi = new OpenAiApi("https://api.siliconflow.cn","sk-nrvjihoykgbjabnelziszukgkcankraqcwtvohvpcuepuyyz");
//        //        return new OpenAiEmbeddingModel(, MetadataMode.EMBED, OpenAiEmbeddingOptions.builder().model("text-embedding-ada-002").build(), RetryUtils.DEFAULT_RETRY_TEMPLATE);
//        return new OpenAiEmbeddingModel(
//                openAiApi,
//                MetadataMode.EMBED,
//                OpenAiEmbeddingOptions.builder()
//                        .dimensions(512)
////                        .dimensions()
//                        .encodingFormat("float")
//                        .model("BAAI/bge-large-zh-v1.5")
//                        .build(),
//                RetryUtils.DEFAULT_RETRY_TEMPLATE);
//    }
//    @Bean(name = "customVectorStore")
//    public VectorStore vectorStore(JedisPooled jedisPooled, EmbeddingModel embeddingModel) {
//        return RedisVectorStore.builder(jedisPooled, embeddingModel)
//                .indexName("custom-index")                // Optional: defaults to "spring-ai-index"
//                .prefix("custom-prefix")                  // Optional: defaults to "embedding:"
//                .metadataFields(                         // Optional: define metadata fields for filtering
//                        RedisVectorStore.MetadataField.text("nationality"),
//                        RedisVectorStore.MetadataField.tag("country"),
//                        RedisVectorStore.MetadataField.numeric("year1"))
//                .initializeSchema(true)                   // Optional: defaults to false
//                .batchingStrategy(new TokenCountBatchingStrategy()) // Optional: defaults to TokenCountBatchingStrategy
//                .build();
//    }
//
//
//}
